import moment from 'moment';

if (module.hot) {
    module.hot.accept();
    if (process.env.NODE_ENV !== 'production') {
        // eslint-disable-next-line
        console.log(`%c 本地开发环境热更新运行正常 %c ${moment().format(`YYYY-MM-DD HH:mm:ss`)}`, 'background:#333;color:white', 'color:red');
    }
}
if (process.env.NODE_ENV === 'production') {
    // eslint-disable-next-line
    console.log('%c MathsGeeker', 'color: #283442; background: -webkit-linear-gradient(orange, green);background: -o-linear-gradient(orange, green);background: -moz-linear-gradient(orange, green);background: linear-gradient(orange, green); font-size: 24px;');
}

require('babel-polyfill');
if (!window.Promise) {
    require('es6-promise').polyfill();
} else if (!window.fetch) {
    require('whatwg-fetch');
}
import React from 'react';
import ReactDOM from 'react-dom';
import { createStore, applyMiddleware, combineReducers } from 'redux';
import thunkMiddleware from 'redux-thunk';
// import { createLogger } from 'redux-logger';
import { composeWithDevTools } from 'redux-devtools-extension';
import { Provider } from 'react-redux';
// import { Router, Route, browserHistory } from 'react-router';
// import { syncHistoryWithStore, routerReducer } from 'react-router-redux';
import {
    BrowserRouter as Router,
    Route,
    Switch,
    // Link,
    // Redirect
} from 'react-router-dom';

import { Layout, notification } from 'antd';
import RootReducer from '../reducers/index';
require('./style.less');

notification.config({ top: 100, });
// eslint-disable-next-line
window.addEventListener('error', (errorMessage, scriptURI, lineNumber, columnNumber, errorObj) => {
    // js error 监控
});
const store = createStore(
    combineReducers(RootReducer),
    composeWithDevTools(
        applyMiddleware(
            thunkMiddleware,
            // createLogger()
        )
    )
);

// 头部
import MyHeader from '../views/common/header/index';
// 主体内容
import MyContent from '../views/common/content/index';
// 404
import NotFound from '../views/common/404/index';
// 登录
import SignIn from '../views/signIn/index';
// 注册
import SignUp from '../views/signUp/index';
// 帮助文档
import Help from '../views/help/index';


class Home extends React.Component {
    constructor(props) {
        super(props);

        this.state = {};
    }
    render() {
        return (
            <div className="rettc-page-container">
                <Provider store={store}>
                    <Router basename="/sign" forceRefresh={!('pushState' in window.history)}>
                        <Layout
                            className="rettc-page-layout"
                        >
                            <MyHeader />
                            <Layout
                                className="rettc-page-main"
                            >
                                <MyContent>
                                    <Switch>
                                        <Route exact path="/" component={SignIn} />
                                        <Route path="/signin" component={SignIn} />
                                        <Route path="/signup" component={SignUp} />
                                        <Route path="/help" component={Help} />
                                        <Route component={NotFound} />
                                        <Route path='/404' component={NotFound} />
                                    </Switch>
                                </MyContent>
                            </Layout>
                        </Layout>
                    </Router>
                </Provider >
            </div>
        )
    }
}

ReactDOM.render(<Home />, document.getElementById('root'));